package com.yanqu.road.server.cmd.orewar.cross;

import com.yanqu.road.entity.crossorewar.CrossUserOrePit;
import com.yanqu.road.entity.player.UserBaseInfo;
import com.yanqu.road.logic.pb.PlayerBasePb;
import com.yanqu.road.pb.orewar.OreWarProto;
import com.yanqu.road.server.cmd.base.AbstractCommand;
import com.yanqu.road.server.command.Cmd;
import com.yanqu.road.server.gameplayer.GamePlayer;
import com.yanqu.road.server.manger.activity.orewar.OreWarMgr;
import com.yanqu.road.server.manger.config.PatronsMgr;
import com.yanqu.road.server.pb.OreWarPb;
import com.yanqu.road.message.YanQuMessage;
import com.yanqu.road.server.protocol.Protocol;

import java.util.List;


@Cmd(code = Protocol.S_CROSS_ORE_WAR_ROBPIT_LOSER, desc = "抢夺矿坑情况跨服返回被占领的玩家发放邮件奖励")
public class CrossRobPitLoserRespCmd extends AbstractCommand {

	private int activityId;
	private long userId;
	private int pitId;
	private String patronsInfoStr;
	private String reward;
	private long enemyUserId;
	private UserBaseInfo enemyBaseData;
	private int groupId;

	@Override
	public boolean parseData(YanQuMessage packet) throws Exception {
		return true;
	}

	@Override
	public void execute(GamePlayer player, YanQuMessage packet) throws Exception {
		OreWarProto.CrossOrePitRobLoserRespMsg crossRespMsg = OreWarProto.CrossOrePitRobLoserRespMsg.parseFrom(packet.getBytes());
		activityId = crossRespMsg.getActivityId();
		userId = crossRespMsg.getUserId();
		pitId = crossRespMsg.getPitId();
		patronsInfoStr = crossRespMsg.getPatronsInfoStr();
		reward = crossRespMsg.getReward();
		enemyUserId = crossRespMsg.getEnemyUserId();
		enemyBaseData = PlayerBasePb.parseBaseUserInfo(crossRespMsg.getEnemyBaseData());
		groupId = crossRespMsg.getGroupId();
		List<Integer> patronIdList = PatronsMgr.parsePatronInfoStrToIdList(patronsInfoStr);
		CrossUserOrePit crossUserOrePit =  OreWarPb.parseCrossUserOrePit(crossRespMsg.getCrossOrePit());

		OreWarMgr.addCrossOreWarRewardMail(activityId,userId,enemyUserId,enemyBaseData,reward,pitId,patronIdList,crossUserOrePit,groupId);
	}

	@Override
	public void sendData(GamePlayer player) {

	}
}
